import service from '@/utils/request'
import { selectDataClient } from '@/utils/common'
// import qs from 'qs'
const {  httpGet, httpPost } = service

const request = {

    // 获取采购结算的列表页数据
    getPurchaseData (params) {
        return httpPost({
            url: '/facilitysettle/buy/advanced/query',
            params
        })
    },
    // 采购结算的新增保存
    purchaseAdd (params) {
        return httpPost({
            url: '/facilitysettle/buy/add',
            params
        })
    },

    // 获取采购结算的基本信息
    getBasicInfo (id) {
        return httpGet({
            url: '/facilitysettle/buy/get',
            params: {
                id
            }
        })
    },
    // 保存基本信息
    basicInfoSave (params) {
        return httpPost({
            url: '/facilitysettle/buy/update',
            params
        })
    },
    // 合同编号
    getContractNo (params, contractId) {
        return new Promise(resolve => {
            selectDataClient({
                SelectServiceToken: '/subcontract/thirdParty/getPurchaseSettlement', // 客户端对应方法名
                IsSingleMode: true, // 是否单选 true 单选 false 多选
                SelectedIDs: contractId, // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[]) // 这个是客户端给的,没有则为空
                InitParamsStr: JSON.stringify(params),    // 接口参数(name为模拟参数)
                Title: '选择采购合同' // 标题
            }).then(res => {
                resolve(res)
            })
        })
        // return httpPost({
        //     url: '/subcontract/thirdParty/getPurchaseSettlement',
        //     params
        // })
    },
    // 结算明细-选择设备
    selectDevice (contractId, ids) {
        return selectDataClient({
            SelectServiceToken: '/facilityconnect/list/receive/dtl', // 客户端对应方法名
            IsSingleMode: false, // 是否单选 true 单选 false 多选
            SelectedIDs: ids, // 已选中id(注意：是上一次已选中的id，不是要传的参数，如果第一次选，则传[]) // 这个是客户端给的,没有则为空
            InitParamsStr: JSON.stringify(contractId),    // 接口参数(name为模拟参数)
            Title: '选择采购验收设备' // 标题
        })
        // return httpGet({
        //     url: '/facilityconnect/list/receive/dtl',
        //     params: {
        //         id
        //     }
        // })
    },

    // 获取采购-结算明旭
    getSettlement (id) {
        return httpGet({
            url: '/facilitysettle/buy/settle/dtl/buy/list',
            params: {
                id
            }
        })
    },

    // 保存采购-结算明细
    settlementSave (params) {
        return httpPost({
            url: '/facilitysettle/buy/settle/dtl/update',
            params
        })
    },

    // 获取采购-服务费用
    getServiceFee (id) {
        return httpGet({
            url: '/facilitysettle/buy/settle/dtl/buy/list/freight',
            params: {
                id
            }
        })
    },
    // 保存服务费用
    serviceFeeSave (params) {
        return httpPost({
            url: '/facilitysettle/buy/settle/dtl/update/freight',
            params
        })
    },

    // 删除租赁结算基本信息
    basicInfoDelete (id) {
        return httpGet({
            url: '/facilitysettle/buy/delete',
            params: {
                id
            }
        })
    },
    // 租赁结算冲红单
    redSingle (id) {
        return httpGet({
            url: '/facilitysettle/buy/rush',
            params: {
                id
            }
        })
    }

}

export default request